<?php

declare (strict_types = 1);

namespace app\store\service;

use app\common\service\BaseService;
use app\common\model\Advertising as AdvertisingModel;
use app\store\model\UploadFile;


/**
 * 广告位管理
 * Class Goods
 * @package app\store\service
 */
class Advertising extends BaseService
{

    /**
     * @param $params
     */
    public function save($params): bool
    {
        $tmp = [];
        foreach ($params['value'] as $item){
            $tmp[] = [
                'image_id' => $item['image_id'],
                'jump_url' => $item['jump_url'],
            ];
        }
        $res = AdvertisingModel::create([
            'value' => json_encode($tmp,JSON_UNESCAPED_UNICODE)
        ]);
        if(!$res->id){
            return false;
        }
        return true;
    }
}
